<template>
	<el-main>
		<el-row :gutter="15">
			<el-col :lg="12">
				<el-card shadow="never" header="新建权限">
					<el-form-item label="授权新建人员" prop="createUserRole">
						<select-user-dialog v-model:accountId="form.createUserRole" :mode="true"/>
					</el-form-item>
					<el-form-item label="授权新建部门" prop="createDeptRole">
						<select-dept-dialog v-model:deptId="form.createDeptRole" :mode="true"/>
					</el-form-item>
					<el-form-item label="授权新建职务" prop="createLevelRole">
						<select-user-level-dialog v-model:levelId="form.createLevelRole" :mode="true"/>
					</el-form-item>
				</el-card>
			</el-col>
			<el-col :lg="12">
				<el-card shadow="never" header="审批权限">
					<el-form-item label="项目审批人员" prop="approvalUserRole">
						<select-user-dialog v-model:accountId="form.approvalUserRole" :mode="false"/>
					</el-form-item>
					<el-form-item label="项目免审批人员" prop="notNeedApprovalRole">
						<select-user-dialog v-model:accountId="form.notNeedApprovalRole" :mode="false"/>
					</el-form-item>
				</el-card>
			</el-col>
		</el-row>
		<div style="text-align: center;">
			<el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</div>
	</el-main>
</template>

<script>
import selectUserDialog from "@/views/module/selectUserDialog";
import selectDeptDialog from "@/views/module/selectDeptDialog";
import selectUserLevelDialog from "@/views/module/selectUserLevelDialog";

export default {
	name: 'Project Role Manage',
	components: {
		selectUserLevelDialog,
		selectUserDialog,
		selectDeptDialog,
	},
	data() {
		return {
			isSaveing: false,
			form: {
				createUserRole: "",
				createDeptRole: "",
				createLevelRole: "",
				approvalUserRole: "",
				notNeedApprovalRole: "",
			}
		}
	},
	mounted() {
		this.getProRoleInfo();
	},
	methods: {
		async submit() {
			var res = await this.$API.project.proRole.setProRole.post(this.form);
			this.isSaveing = false;
			if (res.code == 200) {
				this.$message.success("操作成功")
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getProRoleInfo() {
			var res = await this.$API.project.proRole.getProRoleInfo.get();
			if (res.code == 200) {
				this.form = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		}
	}
}
</script>

<style>
</style>
